
const { addExercise,findExercise} = require('../model/exerciseModel')
const { mongoose } = require('../utils/mongoose')
const moment=require('moment')
//新增
const addExerciseData=async (req,res,next)=>{
    const result=await addExercise(req.body)
    if(result){
        res.send({httpStatus:200,data:result,msg:'增加成功'})
    }else{
        res.send({httpStatus:400,data:[],msg:'增加出错'})
    }
}
//查询
const getExerciseData= async (req, res) => {
    let {id,start,end}=req.body;
    const result = await findExercise({id,start,end});
    if (result.length||result.length===0) {
        res.send({ httpStatus: 200, total: result.length, data: result })
    } else {
        res.send({ httpStatus: 400,  msg: '查询出错',date:[]})
    }
}

module.exports = {
    addExerciseData,
    getExerciseData,
}